#include"game.h"
#include<stdio.h>



/** @name Songs */
/*@{*/
//Marcha Funebre
Note notes_game1[] = {{Re4,250}, {Re4,250}, {Re4,250},{Re4,250},{Sol4,250},{Fa4,250},{Fa4,250},{Re4,250},{Re4,250},{Do4,250},{Re4,250}};
//LP - In the end
Note notes_game2[] = {{Do4, 500}, {La4,500}, {La4, 500}, {Fa4, 500}, {Mi4, 1000}, {Mi4,500}, {Mi4, 500}, {Mi4,250}, {Fa4,500}, {Re4,500},{La4,500}, {La4,500},{Fa4,500}}; 
//Titanic
Note notes_game3[] = {{Fa4, 500}, {Fa4,500}, {Fa4, 500}, {Fa4, 500}, {Mi4, 500}, {Fa4,1000}, {Fa4, 500}, {Mi4,500}, {Fa4,1000}, {Sol4,500},{La4,500}, {Sol4,1000}}; 
//Guns n roses patience
Note notes_game4[] = {{Do4,250},{La4,250}, {Sol4,250},{La4,250},{Si4,250},{La4,250}, {Sol4,250},{Si4,250},{La4,250},{Sol4,250},{La4,250}};
//Balao joao
Note notes_game5[] = {{Do4,250},{Mi4,250},{Mi4,500},{Fa4,250},{Re4,250},{Re4,500},{Do4,250},{Mi4,250},{Re4,250},{Fa4,250},{Sol4,250},{Sol4,250},{Sol4,500}};
/*@}*/


/** @name Global Variables */
/*@{*/
Note player_notes[15];  ///< Array for the notes inserted by the player

int number_songs=5;  ///< Number of songs to be chosen randomly
static char local_table[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x00 */
0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /*character 0x01 */
0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, /*character 0x02 */
0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, /*character 0x03 */
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x04 */
0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x05 */
0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x06 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x07 */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /*character 0x08 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x09 */
0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, /*character 0x0a */
0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, /*character 0x0b */
0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0x0c */
0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00, /*character 0x0d */
0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00, /*character 0x0e */
0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0x0f */
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, /*character 0x10 */
0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, /*character 0x11 */
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x12 */
0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, /*character 0x13 */
0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00, /*character 0x14 */
0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, /*character 0x15 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, /*character 0x16 */
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, /*character 0x17 */
0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0x18 */
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0x19 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x1a */
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x1b */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x1c */
0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6c, 0xfe, 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x1d */
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x1e */
0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x1f */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x20 */
0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0x21 */
0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x22 */
0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, /*character 0x23 */
0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, 0x06, 0x06, 0x86, 0xc6, 0x7c, 0x18, 0x18, 0x00, 0x00, /*character 0x24 */
0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, 0x00, 0x00, 0x00, 0x00, /*character 0x25 */
0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0x26 */
0x00, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x27 */
0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, /*character 0x28 */
0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, /*character 0x29 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x2a */
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x2b */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, /*character 0x2c */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x2d */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0x2e */
0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, /*character 0x2f */
0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xd6, 0xd6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, /*character 0x30 */
0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, /*character 0x31 */
0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, /*character 0x32 */
0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x33 */
0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00, /*character 0x34 */
0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x35 */
0x00, 0x00, 0x38, 0x60, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x36 */
0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, /*character 0x37 */
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x38 */
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00, /*character 0x39 */
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x3a */
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, /*character 0x3b */
0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00, /*character 0x3c */
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x3d */
0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, /*character 0x3e */
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0x3f */
0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x40 */
0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x41 */
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00, /*character 0x42 */
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x43 */
0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00, /*character 0x44 */
0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, /*character 0x45 */
0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, /*character 0x46 */
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00, /*character 0x47 */
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x48 */
0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x49 */
0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, /*character 0x4a */
0x00, 0x00, 0xe6, 0x66, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, /*character 0x4b */
0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, /*character 0x4c */
0x00, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x4d */
0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x4e */
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x4f */
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, /*character 0x50 */
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00, /*character 0x51 */
0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, /*character 0x52 */
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x53 */
0x00, 0x00, 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x54 */
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x55 */
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, /*character 0x56 */
0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0xee, 0x6c, 0x00, 0x00, 0x00, 0x00, /*character 0x57 */
0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x7c, 0x38, 0x38, 0x7c, 0x6c, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x58 */
0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x59 */
0x00, 0x00, 0xfe, 0xc6, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, /*character 0x5a */
0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x5b */
0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, /*character 0x5c */
0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x5d */
0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x5e */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, /*character 0x5f */
0x00, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x60 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0x61 */
0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x62 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x63 */
0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0x64 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x65 */
0x00, 0x00, 0x1c, 0x36, 0x32, 0x30, 0x78, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0x00, /*character 0x66 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xcc, 0x78, 0x00, /*character 0x67 */
0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, /*character 0x68 */
0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x69 */
0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00, /*character 0x6a */
0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, /*character 0x6b */
0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x6c */
0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xd6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x6d */
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, /*character 0x6e */
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x6f */
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, /*character 0x70 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00, /*character 0x71 */
0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, /*character 0x72 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x73 */
0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, /*character 0x74 */
0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0x75 */
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, /*character 0x76 */
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00, 0x00, 0x00, 0x00, /*character 0x77 */
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x78 */
0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00, /*character 0x79 */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, /*character 0x7a */
0x00, 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00, /*character 0x7b */
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0x7c */
0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, /*character 0x7d */
0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x7e */
0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0x7f */
0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x18, 0x70, 0x00, 0x00, /*character 0x80 */
0x00, 0x00, 0xcc, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0x81 */
0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x82 */
0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0x83 */
0x00, 0x00, 0x76, 0xdc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0x84 */
0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0x85 */
0x60, 0xc0, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x86 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x18, 0x70, 0x00, 0x00, /*character 0x87 */
0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x88 */
0x38, 0x6c, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, /*character 0x89 */
0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x8a */
0x0c, 0x18, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x8b */
0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x8c */
0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x8d */
0x76, 0xdc, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x8e */
0x38, 0x6c, 0xc6, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x8f */
0x0c, 0x18, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, /*character 0x90 */
0x0c, 0x06, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x91 */
0x30, 0x18, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, /*character 0x92 */
0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x93 */
0x00, 0x00, 0x76, 0xdc, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x94 */
0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x95 */
0x18, 0x30, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x96 */
0x00, 0x60, 0x30, 0x18, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0x97 */
0x30, 0x18, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0x98 */
0x76, 0xdc, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x99 */
0x00, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x9a */
0x00, 0x18, 0x18, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0x9b */
0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00, /*character 0x9c */
0x30, 0x18, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x9d */
0x00, 0xf8, 0xcc, 0xcc, 0xf8, 0xc4, 0xcc, 0xde, 0xcc, 0xcc, 0xcc, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0x9e */
0x18, 0x30, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0x9f */
0x00, 0x18, 0x30, 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0xa0 */
0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0xa1 */
0x00, 0x18, 0x30, 0x60, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0xa2 */
0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0xa3 */
0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, /*character 0xa4 */
0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0xa5 */
0x00, 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xa6 */
0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xa7 */
0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0xa8 */
0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, /*character 0xa9 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xaa */
0x00, 0x60, 0xe0, 0x62, 0x66, 0x6c, 0x18, 0x30, 0x60, 0xdc, 0x86, 0x0c, 0x18, 0x3e, 0x00, 0x00, /*character 0xab */
0x00, 0x60, 0xe0, 0x62, 0x66, 0x6c, 0x18, 0x30, 0x66, 0xce, 0x9a, 0x3f, 0x06, 0x06, 0x00, 0x00, /*character 0xac */
0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0xad */
0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xae */
0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xaf */
0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, /*character 0xb0 */
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, /*character 0xb1 */
0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, /*character 0xb2 */
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xb3 */
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xb4 */
0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xb5 */
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xb6 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xb7 */
0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xb8 */
0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xb9 */
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xba */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xbb */
0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xbc */
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xbd */
0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xbe */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xbf */
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xc0 */
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xc1 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xc2 */
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xc3 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xc4 */
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xc5 */
0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xc6 */
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xc7 */
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xc8 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xc9 */
0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xca */
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xcb */
0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xcc */
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xcd */
0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xce */
0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xcf */
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xd0 */
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xd1 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xd2 */
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xd3 */
0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xd4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xd5 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xd6 */
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, /*character 0xd7 */
0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xd8 */
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xd9 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xda */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /*character 0xdb */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /*character 0xdc */
0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, /*character 0xdd */
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, /*character 0xde */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xdf */
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, 0x00, 0x00, 0x00, /*character 0xe0 */
0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0x00, 0x00, 0x00, 0x00, /*character 0xe1 */
0x00, 0x00, 0xfe, 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, /*character 0xe2 */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, /*character 0xe3 */
0x00, 0x00, 0xfe, 0xc6, 0x60, 0x30, 0x18, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, /*character 0xe4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, /*character 0xe5 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, /*character 0xe6 */
0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, /*character 0xe7 */
0x00, 0x00, 0x7e, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, /*character 0xe8 */
0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, /*character 0xe9 */
0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 0x00, 0x00, 0x00, 0x00, /*character 0xea */
0x00, 0x00, 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, /*character 0xeb */
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xec */
0x00, 0x00, 0x00, 0x03, 0x06, 0x7e, 0xdb, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, /*character 0xed */
0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00, /*character 0xee */
0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, /*character 0xef */
0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xf0 */
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, /*character 0xf1 */
0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, /*character 0xf2 */
0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, /*character 0xf3 */
0x00, 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, /*character 0xf4 */
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, /*character 0xf5 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xf6 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xf7 */
0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xf8 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xf9 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xfa */
0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00, /*character 0xfb */
0x00, 0x6c, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xfc */
0x00, 0x3c, 0x66, 0x0c, 0x18, 0x32, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xfd */
0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xfe */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*character 0xff */
};  ///< Table to print char's in graphic mode

int number_player_notes=0;  ///< Number os notes inserted by the player
Song game_song;  ///< Song randomly chosen by the game

int list_xi[15]; ///< List of initial x's for the equalizer
int list_y[15]; ///< List of y's for the equalizer
int list_xf[15]; ///< List of final x's for the equalizer

int list_player_xi[15]; ///< List of initial x's for the equalizer (player song)
int list_player_y[15]; ///< List of y's for the equalizer (player song)
int list_player_xf[15]; ///< List of final x's for the equalizer (player song)

int size_game_song; ///< Number of notes of the game song

int rtc_a_ints = 0; ///< Alarm Flag
int HRES=800; ///< Horizontal Resolution
int VRES=600; ///< Vertical Resolution

/*@}*/

/** Funcao que limpa o ecra com a cor definida
 *
*/
void cleanscreen()
{
	system("cls"); //Limpa o ecra
	fillScreen(LIGHTGRAY_BACK);
}

/** Desenha um menu e permite escolher a duracao da nota
 *
*/
Note choose_duration(menu_notas escolha, int edit)
{
	menu_duration esc_dur=HALF;
	menu_duration last_position=BACK;
	int last_sc = 0;
	Bool first =false;
	Note nt;
	
	do
	{		
		if(scancode!=last_sc)
		{
			last_sc=scancode;
			
			drawFrame("Duration", LIGHTGRAY_BACK | BLUE_FOREG, 49,17,21,6);
			drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 51,18,5,3);
			drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 57,18,5,3);
			drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 63,18,5,3);
			drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 55,21,6,3);
			
			printStringAt("0.5",52,19,LIGHTGRAY_BACK);
			printStringAt("1",59,19,LIGHTGRAY_BACK);
			printStringAt("2",65,19,LIGHTGRAY_BACK);
			printStringAt("Back",56,22,LIGHTGRAY_BACK);
		
			switch(esc_dur)
			{
				case HALF:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 51,18,5,3);
					break;
				case ONE:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 57,18,5,3);
					break;
				case TWO:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 63,18,5,3);
					break;
				case BACK:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 55,21,6,3);
				break;
			}
		
			if(last_sc==RIGHT)
			{
				if(esc_dur==TWO)
					esc_dur=HALF;
				else if(esc_dur!=BACK)
					esc_dur++;
			}
			else if(last_sc==LEFT)
			{
				if(esc_dur==HALF)
					esc_dur=TWO;
				else if(esc_dur!=BACK)
					esc_dur--;
			}
			else if(last_sc==DOWN)
			{
				if(esc_dur!=BACK)
					last_position=esc_dur;
				esc_dur=BACK;
			}
			else if(last_sc==UP)
			{
				if(esc_dur==BACK)
					esc_dur=last_position;
			}
			else if(last_sc==END)
			{
				if(esc_dur!=BACK)
				{
					play_n(escolha,esc_dur);
				}
			}
			else if(last_sc==ENTER)
			{
				if(esc_dur!=BACK && first==true)
				{
					if(edit==-1)
						player_notes[number_player_notes++]=selected_note(escolha,esc_dur);
					else
						player_notes[edit]=selected_note(escolha,esc_dur);
					esc_dur=BACK;
				}
			}
			first=true;
		}
		else
		{
			RTC_TIME time_game;
			RTC_TIME limit;
			rtc_read_time(&time_game);
			rtc_read_alarm(&limit);
			
			int total_limit,total_time;
			total_time=3600*time_game.hour+60*time_game.min+time_game.sec;
			total_limit=3600*limit.hour+60*limit.min+limit.sec;
			total_limit-=total_time;

			limit.hour=0;
			limit.min=(int)(total_limit/60);
			limit.sec=total_limit%60;
			
			if(!total_limit)
				rtc_a_ints=1;
				
			printf("\t\t\t\t\t\t\tTime left: %i:%i:%i\r",limit.hour,limit.min,limit.sec);
		}
	}while((esc_dur!=BACK || last_sc!=ENTER)&&!rtc_a_ints);
	return nt; 	
}

/** Funcao com o menu inicial do jogo, com a lista de notas a escolher, notas inseridas pelo utilizador que
 * recebe o nome do jogador e retorna a pontuacao por ele feita
*/
int start_game(char* player)
{
	cleanscreen();
	random_song();
	Note nt;
	//Song sg;
	menu_notas escolha=DO;//predefinir a esolha selecionada como "Play"
	menu_notas last_position=Surrender;
	user_notes escolha_user=None;
	_go32_dpmi_seginfo old_kbd_irq;
	//_go32_dpmi_seginfo old_rtc_irq;
	rtc_a_ints = 0;
	int last_sc = 0;
	int edit=-1;
	int score=0;
	int time_left;
	int attempt_equalizer=0;
	Bool first =false;
	//Instala handler das interrupcoes do teclado e rtc
		install_asm_irq_handler(KBD_IRQ, kbd_isr, &old_kbd_irq);
		//install_c_irq_handler(RTC_IRQ, rtc_isr, &old_rtc_irq);
		
		//rtc_ints_enable();
	
	//Coloca limite de 5min no alarme
	RTC_TIME time;
	rtc_read_time(&time);
	time.min+=5;
	if(time.min >= 60)
	{
		time.min -= 60;
		++time.hour;
		if(time.hour == 24)
			time.hour=0;
	}
	rtc_write_alarm(&time);
	do
	{	
		
		if(scancode!=last_sc)
		{
		last_sc=scancode;

		drawFrame("KEYS", LIGHTGRAY_BACK | BLUE_FOREG, 2,12,55,5);
		drawFrame("PageUp", LIGHTGRAY_BACK | BLUE_FOREG, 3,13,8,3);
		printStringAt("Music",4,14,LIGHTGRAY_BACK);
		drawFrame("PageDown", LIGHTGRAY_BACK | BLUE_FOREG, 12,13,10,3);
		printStringAt("YourSong",13,14,LIGHTGRAY_BACK);
		drawFrame("End", LIGHTGRAY_BACK | BLUE_FOREG, 23,13,10,3);
		printStringAt("PlayNote",24,14,LIGHTGRAY_BACK);
		drawFrame("Del", LIGHTGRAY_BACK | BLUE_FOREG, 34,13,8,3);
		printStringAt("Delete",35,14,LIGHTGRAY_BACK);
		drawFrame("Enter", LIGHTGRAY_BACK | BLUE_FOREG, 43,13,13,3);
		printStringAt("Insert/Edit",44,14,LIGHTGRAY_BACK);
		
		drawFrame("Notes", LIGHTGRAY_BACK | BLUE_FOREG, 3,17,45,6);
		drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 5,18,4,3);
		drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 10,18,4,3);
		drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 15,18,4,3);
		drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 20,18,4,3);
		drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 25,18,5,3);
		drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 31,18,4,3);
		drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 36,18,4,3);
		drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, 41,18,5,3);
		drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, WIDTH/4,21,11,3);
		printStringAt("Do",6,19,LIGHTGRAY_BACK);
		printStringAt("Re",11,19,LIGHTGRAY_BACK);
		printStringAt("Mi",16,19,LIGHTGRAY_BACK);
		printStringAt("Fa",21,19,LIGHTGRAY_BACK);
		printStringAt("Sol",26,19,LIGHTGRAY_BACK);
		printStringAt("La",32,19,LIGHTGRAY_BACK);
		printStringAt("Si",37,19,LIGHTGRAY_BACK);
		printStringAt("Dos",42,19,LIGHTGRAY_BACK);
		printStringAt("Surrender",WIDTH/4+1,22,LIGHTGRAY_BACK);
		
		if(number_player_notes>0)
		{
			int i=0;
			while(i!=number_player_notes)
			{
				drawNote(3+i*5,1,&player_notes[i],false);
				++i;
			}
		}
		if(escolha!=NoNotas)
		{
			switch(escolha)
			{
				case DO:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 5,18,4,3);
					break;
				case RE:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 10,18,4,3);
					break;
				case MI:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 15,18,4,3);
					break;
				case FA:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 20,18,4,3);
					break;
				case SOL:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 25,18,5,3);
					break;
				case LA:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 31,18,4,3);
					break;
				case SI:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 36,18,4,3);
					break;
				case DOs:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, 41,18,5,3);
					break;
				case Surrender:
					drawFrame("", LIGHTGRAY_BACK | RED_FOREG, WIDTH/4,21,11,3);
					break;
				case NoNotas:
					break;
			}
		}
		else
		{
			switch(escolha_user)
			{
				case(Note1):
					drawNote(3,1,&player_notes[0],true);
					break;
				case(Note2):
					drawNote(8,1,&player_notes[1],true);
					break;
				case(Note3):
					drawNote(13,1,&player_notes[2],true);
					break;
				case(Note4):
					drawNote(18,1,&player_notes[3],true);
					break;
				case(Note5):
					drawNote(23,1,&player_notes[4],true);
					break;
				case(Note6):
					drawNote(28,1,&player_notes[5],true);
					break;
				case(Note7):
					drawNote(33,1,&player_notes[6],true);
					break;
				case(Note8):
					drawNote(38,1,&player_notes[7],true);
					break;
				case(Note9):
					drawNote(43,1,&player_notes[8],true);
					break;
				case(Note10):
					drawNote(48,1,&player_notes[9],true);
					break;
				case(Note11):
					drawNote(53,1,&player_notes[10],true);
					break;
				case(Note12):
					drawNote(58,1,&player_notes[11],true);
					break;
				case(Note13):
					drawNote(63,1,&player_notes[12],true);
					break;
				case(Note14):
					drawNote(68,1,&player_notes[13],true);
					break;
				case(Note15):
					drawNote(73,1,&player_notes[14],true);
					break;
				case(None):
					break;
			}
		}
		
		if(last_sc==RIGHT)
		{
			if(escolha!=NoNotas)
			{
				if(escolha==DOs)
					escolha=DO;
				else if(escolha!=Surrender)
					escolha++;
			}
			else
			{
				if(number_player_notes==escolha_user)
					escolha_user=Note1;
				else if(number_player_notes>escolha_user)
					++escolha_user;
			}
		}
		else if(last_sc==LEFT)
		{
			if(escolha!=NoNotas)
			{
				if(escolha==DO)
					escolha=DOs;
				else if(escolha!=Surrender)
					escolha--;
			}
			else
			{
				if(escolha_user==Note1)
					escolha_user=number_player_notes;
				else
					--escolha_user;
			}
		}
		else if(last_sc==DOWN)
		{
			if(escolha!=NoNotas)
			{
				if(escolha!=Surrender)
					last_position=escolha;
				escolha=Surrender;
			}
			else
			{
				escolha_user=None;
				escolha=DO;
			}
		}
		else if(last_sc==UP)
		{
			if(escolha!=NoNotas)
			{
				if(escolha==Surrender)
					escolha=last_position;
				else if(escolha!=NoNotas && number_player_notes>0)
				{
					escolha=NoNotas;
					escolha_user=Note1;
				}
			}
		}
		else if(last_sc==ENTER && first==true)
		{
			if(escolha!=NoNotas)
			{
				if(escolha!=Surrender)
				{
					nt = choose_duration(escolha,edit);
					cleanscreen();
					edit=-1;
				}
			}
			else
			{
				edit=escolha_user-1;
				escolha=DO;
				escolha_user=None;
			}
		}
		else if(last_sc==PDOWN)
		{
			play_user_song();
		}
		else if(last_sc==DEL)
		{
			if(escolha==NoNotas)
			{
				delete_user_note(escolha_user);
				cleanscreen();
			}
			if(number_player_notes<escolha_user)
				--escolha_user;
		}
		else if(last_sc==PUP)
		{
			play_game_song();
		}
		else if(last_sc==HOME)
		{
			if(attempt_equalizer==0)
			{
				reinstall_asm_irq_handler(KBD_IRQ, &old_kbd_irq);
				makepoints();
				equalizer();
				cleanscreen();
				install_asm_irq_handler(KBD_IRQ, kbd_isr, &old_kbd_irq);
				attempt_equalizer=1;
			}
		}
		first=true;
		}	
		
		RTC_TIME time_game;
		RTC_TIME limit;
		rtc_read_time(&time_game);
		rtc_read_alarm(&limit);
		
		int total_limit,total_time;
		total_time=3600*time_game.hour+60*time_game.min+time_game.sec;
		total_limit=3600*limit.hour+60*limit.min+limit.sec;
		total_limit-=total_time;
		time_left=total_limit;
		limit.hour=0;
		limit.min=(int)(total_limit/60);
		limit.sec=total_limit%60;
		
		if(total_limit<=0)
			rtc_a_ints=1;
		
		printf("\t\t\t\t\t\t\tTime left: %i:%i:%i\r",limit.hour,limit.min,limit.sec);
		score=notas_correctas()*100;
	}while((escolha!=Surrender || last_sc!=ENTER)&&!rtc_a_ints&&(!comparar_musica()));
	
	cleanscreen();
	
	if(comparar_musica())
	{
		score+=time_left*5;
		drawFrame("Parabens", LIGHTGRAY_BACK | BLUE_FOREG, 26,4,27,3);
		printStringAt("Adivinhou todas as notas!",27,5,LIGHTGRAY_BACK);
		drawFrame("Score", LIGHTGRAY_BACK | BLUE_FOREG, 35,15,9,3);
		if(score==0)
			printIntAt(score,39,16,LIGHTGRAY_BACK);
		else if(score<1000)
			printIntAt(score,38,16,LIGHTGRAY_BACK);
		else
			printIntAt(score,37,16,LIGHTGRAY_BACK);
		play_game_song();
	}
	else
	{
		drawFrame("Que Pena!", LIGHTGRAY_BACK | BLUE_FOREG, 24,4,33,3);
		printStringAt("Nao conseguiu terminar a tempo!",25,5,LIGHTGRAY_BACK);
		drawFrame("Score", LIGHTGRAY_BACK | BLUE_FOREG, 35,15,9,3);
		if(score==0)
			printIntAt(score,39,16,LIGHTGRAY_BACK);
		else if(score<1000)
			printIntAt(score,38,16,LIGHTGRAY_BACK);
		else
			printIntAt(score,37,16,LIGHTGRAY_BACK);
		play_game_song();
	}
	add_highscore(score,player);
	number_player_notes=0;
	return score;
}

/** Toca o sample da nota selecionado com determinada duracao
 *
*/
void play_n(menu_notas escolha, menu_duration esc_dur)
{
	timer_init(0, LCOM_MODE);
	timer_init(2, LCOM_MODE);
	timer_load(0, get_divider(1000.0));
	_go32_dpmi_seginfo old_t0_irq;
	install_asm_irq_handler(T0_IRQ, asm_wait, &old_t0_irq);
	
	switch(escolha)
	{
		case(DO):
			if(esc_dur==HALF)
			{
				Note nt={Do4,500};
				play_note(&nt);	
			}
			else if(esc_dur==ONE)
			{
				Note nt={Do4,1000};
				play_note(&nt);	
			}
			else if(esc_dur==TWO)
			{
				Note nt={Do4,2000};
				play_note(&nt);	
			}
			break;
		case(RE):
			if(esc_dur==HALF)
			{
				Note nt={Re4,500};
				play_note(&nt);	
			}
			else if(esc_dur==ONE)
			{
				Note nt={Re4,1000};
				play_note(&nt);	
			}
			else if(esc_dur==TWO)
			{
				Note nt={Re4,2000};
				play_note(&nt);	
			}
			break;
		case(MI):
			if(esc_dur==HALF)
			{
				Note nt={Mi4,500};
				play_note(&nt);	
			}
			else if(esc_dur==ONE)
			{
				Note nt={Mi4,1000};
				play_note(&nt);	
			}
			else if(esc_dur==TWO)
			{
				Note nt={Mi4,2000};
				play_note(&nt);	
			}
			break;
		case(FA):
			if(esc_dur==HALF)
			{
				Note nt={Fa4,500};
				play_note(&nt);	
			}
			else if(esc_dur==ONE)
			{
				Note nt={Fa4,1000};
				play_note(&nt);	
			}
			else if(esc_dur==TWO)
			{
				Note nt={Fa4,2000};
				play_note(&nt);	
			}
			break;
		case(SOL):
			if(esc_dur==HALF)
			{
				Note nt={Sol4,500};
				play_note(&nt);	
			}
			else if(esc_dur==ONE)
			{
				Note nt={Sol4,1000};
				play_note(&nt);	
			}
			else if(esc_dur==TWO)
			{
				Note nt={Sol4,2000};
				play_note(&nt);	
			}
			break;
		case(LA):
			if(esc_dur==HALF)
			{
				Note nt={La4,500};
				play_note(&nt);	
			}
			else if(esc_dur==ONE)
			{
				Note nt={La4,1000};
				play_note(&nt);	
			}
			else if(esc_dur==TWO)
			{
				Note nt={La4,2000};
				play_note(&nt);	
			}
			break;
		case(SI):
			if(esc_dur==HALF)
			{
				Note nt={Si4,500};
				play_note(&nt);	
			}
			else if(esc_dur==ONE)
			{
				Note nt={Si4,1000};
				play_note(&nt);	
			}
			else if(esc_dur==TWO)
			{
				Note nt={Si4,2000};
				play_note(&nt);	
			}
			break;
		case(DOs):
			if(esc_dur==HALF)
			{
				Note nt={Do5,500};
				play_note(&nt);	
			}
			else if(esc_dur==ONE)
			{
				Note nt={Do5,1000};
				play_note(&nt);	
			}
			else if(esc_dur==TWO)
			{
				Note nt={Do5,2000};
				play_note(&nt);	
			}
			break;
		case(Surrender):
			break;
		case(NoNotas):
			break;
	}
	
	reinstall_asm_irq_handler(T0_IRQ, &old_t0_irq);
}

/** Devolve a nota selecionada pelo jogador
 *
*/
Note selected_note(menu_notas escolha, menu_duration esc_dur)
{
	Note nota;
	switch(escolha)
	{
		case(DO):
			if(esc_dur==HALF)
			{
				Note nt={Do4,250};
				return nt;
			}
			else if(esc_dur==ONE)
			{
				Note nt={Do4,500};
				return nt;
			}
			else if(esc_dur==TWO)
			{
				Note nt={Do4,1000};
				return nt;
			}
			break;
		case(RE):
			if(esc_dur==HALF)
			{
				Note nt={Re4,250};
				return nt;
			}
			else if(esc_dur==ONE)
			{
				Note nt={Re4,500};
				return nt;
			}
			else if(esc_dur==TWO)
			{
				Note nt={Re4,1000};
				return nt;
			}
			break;
		case(MI):
			if(esc_dur==HALF)
			{
				Note nt={Mi4,250};
				return nt;
			}
			else if(esc_dur==ONE)
			{
				Note nt={Mi4,500};
				return nt;
			}
			else if(esc_dur==TWO)
			{
				Note nt={Mi4,1000};
				return nt;
			}
			break;
		case(FA):
			if(esc_dur==HALF)
			{
				Note nt={Fa4,250};
				return nt;
			}
			else if(esc_dur==ONE)
			{
				Note nt={Fa4,500};
				return nt;
			}
			else if(esc_dur==TWO)
			{
				Note nt={Fa4,1000};
				return nt;
			}
			break;
		case(SOL):
			if(esc_dur==HALF)
			{
				Note nt={Sol4,250};
				return nt;
			}
			else if(esc_dur==ONE)
			{
				Note nt={Sol4,500};
				return nt;
			}
			else if(esc_dur==TWO)
			{
				Note nt={Sol4,1000};
				return nt;
			}
			break;
		case(LA):
			if(esc_dur==HALF)
			{
				Note nt={La4,250};
				return nt;
			}
			else if(esc_dur==ONE)
			{
				Note nt={La4,500};
				return nt;
			}
			else if(esc_dur==TWO)
			{
				Note nt={La4,1000};
				return nt;
			}
			break;
		case(SI):
			if(esc_dur==HALF)
			{
				Note nt={Si4,250};
				return nt;
			}
			else if(esc_dur==ONE)
			{
				Note nt={Si4,500};
				return nt;
			}
			else if(esc_dur==TWO)
			{
				Note nt={Si4,1000};
				return nt;
			}
			break;
		case(DOs):
			if(esc_dur==HALF)
			{
				Note nt={Do5,250};
				return nt;
			}
			else if(esc_dur==ONE)
			{
				Note nt={Do5,500};
				return nt;
			}
			else if(esc_dur==TWO)
			{
				Note nt={Do5,1000};
				return nt;
			}
			break;
		case(Surrender):
			break;
		case(NoNotas):
			break;
	}
	return nota;
}

/** Funcao que desennha uma nota inserida pelo jogador
 *
*/
void drawNote(int x, int y, Note* nt,Bool select)
{
	if(!select)
	{
	drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, x,y,5,3);
	drawFrame("", LIGHTGRAY_BACK | BLUE_FOREG, x,y,5,5);
	}
	else
	{
	drawFrame("", LIGHTGRAY_BACK | RED_FOREG, x,y,5,3);
	drawFrame("", LIGHTGRAY_BACK | RED_FOREG, x,y,5,5);
	}
	switch(nt->freq)
	{
		case(Do4):
			printStringAt("Do",x+1,y+1,LIGHTGRAY_BACK);
			if(nt->dur==250)
				printStringAt("0.5",x+1,y+3,LIGHTGRAY_BACK);
			else if(nt->dur==500)
				printStringAt("1",x+2,y+3,LIGHTGRAY_BACK);
			else
				printStringAt("2",x+2,y+3,LIGHTGRAY_BACK);
			break;
		case(Re4):
			printStringAt("Re",x+1,y+1,LIGHTGRAY_BACK);
			if(nt->dur==250)
				printStringAt("0.5",x+1,y+3,LIGHTGRAY_BACK);
			else if(nt->dur==500)
				printStringAt("1",x+2,y+3,LIGHTGRAY_BACK);
			else
				printStringAt("2",x+2,y+3,LIGHTGRAY_BACK);
			break;
		case(Mi4):
			printStringAt("Mi",x+1,y+1,LIGHTGRAY_BACK);
			if(nt->dur==250)
				printStringAt("0.5",x+1,y+3,LIGHTGRAY_BACK);
			else if(nt->dur==500)
				printStringAt("1",x+2,y+3,LIGHTGRAY_BACK);
			else
				printStringAt("2",x+2,y+3,LIGHTGRAY_BACK);
			break;
		case(Fa4):
			printStringAt("Fa",x+1,y+1,LIGHTGRAY_BACK);
			if(nt->dur==250)
				printStringAt("0.5",x+1,y+3,LIGHTGRAY_BACK);
			else if(nt->dur==500)
				printStringAt("1",x+2,y+3,LIGHTGRAY_BACK);
			else
				printStringAt("2",x+2,y+3,LIGHTGRAY_BACK);
			break;
		case(Sol4):
			printStringAt("Sol",x+1,y+1,LIGHTGRAY_BACK);
			if(nt->dur==250)
				printStringAt("0.5",x+1,y+3,LIGHTGRAY_BACK);
			else if(nt->dur==500)
				printStringAt("1",x+2,y+3,LIGHTGRAY_BACK);
			else
				printStringAt("2",x+2,y+3,LIGHTGRAY_BACK);
			break;
		case(La4):
			printStringAt("La",x+1,y+1,LIGHTGRAY_BACK);
			if(nt->dur==250)
				printStringAt("0.5",x+1,y+3,LIGHTGRAY_BACK);
			else if(nt->dur==500)
				printStringAt("1",x+2,y+3,LIGHTGRAY_BACK);
			else
				printStringAt("2",x+2,y+3,LIGHTGRAY_BACK);
			break;
		case(Si4):
			printStringAt("Si",x+1,y+1,LIGHTGRAY_BACK);
			if(nt->dur==250)
				printStringAt("0.5",x+1,y+3,LIGHTGRAY_BACK);
			else if(nt->dur==500)
				printStringAt("1",x+2,y+3,LIGHTGRAY_BACK);
			else
				printStringAt("2",x+2,y+3,LIGHTGRAY_BACK);
			break;
		case(Do5):
			printStringAt("Dos",x+1,y+1,LIGHTGRAY_BACK);
			if(nt->dur==250)
				printStringAt("0.5",x+1,y+3,LIGHTGRAY_BACK);
			else if(nt->dur==500)
				printStringAt("1",x+2,y+3,LIGHTGRAY_BACK);
			else
				printStringAt("2",x+2,y+3,LIGHTGRAY_BACK);
			break;
		case(NoNotas):
			break;
	}
}

/** Funcao que toca o conjunto de notas inseridas pelo jogador
 *
*/
void play_user_song()
{
	timer_init(0, LCOM_MODE);
	timer_init(2, LCOM_MODE);
	timer_load(0, get_divider(1000.0));
	_go32_dpmi_seginfo old_t0_irq;
	install_asm_irq_handler(T0_IRQ, asm_wait, &old_t0_irq);
	
	Note notes[15];
	int i;
	//Cria-se um array apenas com as notas inseridas pelo utilizador que devem tocar 
	for(i=0; i<number_player_notes;i++)
		notes[i]=player_notes[i];
	
	Song s = { number_player_notes, 10, notes};
	play_song(&s);
	
	reinstall_asm_irq_handler(T0_IRQ, &old_t0_irq);
}

/** Funcao que apaga do array de notas a nota selecionado pelo jogador atraves da tecla DEL
 *
*/
void delete_user_note(user_notes esc_nota)
{
	int i;
	//Apaga a repectiva nota do array
	for(i=0;i<number_player_notes;i++)
	{
		if(i>=(esc_nota-1))
			player_notes[i]=player_notes[i+1];
	}
	--number_player_notes;
}

/** Funcao que escolhe aleatoriamente uma musica para o jogo
 *
*/
void random_song()
{
	
	int r=rand()%number_songs;
	if(r==0)
	{
		Song n={ sizeof(notes_game1)/sizeof(Note), 10, notes_game1};
		game_song=n;
	}
	else if(r==1)
	{
		Song n={ sizeof(notes_game2)/sizeof(Note), 10, notes_game2};
		game_song=n;
	}
	else if(r==2)
	{
		Song n={ sizeof(notes_game3)/sizeof(Note), 10, notes_game3};
		game_song=n;
	}
	else if(r==3)
	{
		Song n={ sizeof(notes_game4)/sizeof(Note), 10, notes_game4};
		game_song=n;
	}
	else if(r==4)
	{
		Song n={ sizeof(notes_game5)/sizeof(Note), 10, notes_game5};
		game_song=n;
	}
}

/** Funcao que toca a musica selecionada aleatoriamente pelo jogo
 *
*/
void play_game_song()
{
	timer_init(0, LCOM_MODE);
	timer_init(2, LCOM_MODE);
	timer_load(0, get_divider(1000.0));
	_go32_dpmi_seginfo old_t0_irq;
	install_asm_irq_handler(T0_IRQ, asm_wait, &old_t0_irq);
	
	play_song(&game_song);
	
	reinstall_asm_irq_handler(T0_IRQ, &old_t0_irq);
}

/** Retorna o numero de notas acertadas pelo jogador
 *
*/
int notas_correctas()
{
	int i=0;
	int correctas=0;
	for(i=0;i<number_player_notes;i++)
	{
		if(game_song.notes[i].freq==player_notes[i].freq && game_song.notes[i].dur==player_notes[i].dur)
		{
			++correctas;
		}
	}
	return correctas;
}

/** Verifica se o jogador acertou a musica toda
 *
*/
int comparar_musica()
{
	if(notas_correctas()==game_song.lenght)
		return 1;
	return 0;
}

/** Funcao que entra no modo grafico e desenha o equalizador da musica do jogo e das notas ja
 * inseridas pelo utilizador
*/
int equalizer()
{
	char * video_mem;
	__dpmi_meminfo *map;
	
	video_mem = enter_graphics(0x103, map);
	
	clear_screen(10,video_mem);
	
	drawStringAt("GAME SONG",350,0,0,5,1,video_mem,local_table);
	drawStringAt("USER SONG",350,300,0,5,1,video_mem,local_table);
	draw_line(0,300,800,300,31,video_mem);
	
	int i;
	//Desenha o equalizador referente as notas a acertar
	for(i=0;i<size_game_song;i++)
	{
		draw_line(list_xi[i],list_y[i],list_xf[i],list_y[i],31,video_mem);
	}
	
	//Desenha o equalizador referente as notas colocadas pelo utilizador
	for(i=0;i<number_player_notes;i++)
	{
		draw_line(list_player_xi[i],list_player_y[i],list_player_xf[i],list_player_y[i],31,video_mem);
	}
	
	getch();
	
	leave_graphics(*map);
	return 0;
}

/** Funcao que preenche os arrays com as listagens de pontos a desenhar no equalizador
 *
*/
void makepoints()
{
	size_game_song=game_song.lenght;
	int i;
	for(i=0;i<size_game_song;i++)
	{
		switch(game_song.notes[i].freq)
		{
			case Do4:
				list_xi[i]=i*HRES/size_game_song;
				list_xf[i]=list_xi[i] + HRES/size_game_song*game_song.notes[i].dur/1000*0.9;
				list_y[i]=VRES/20;
				break;
			case Re4:
				list_xi[i]=i*HRES/size_game_song;
				list_xf[i]=list_xi[i] + HRES/size_game_song*game_song.notes[i].dur/1000*0.9;
				list_y[i]=2*VRES/20;
				break;
			case Mi4:
				list_xi[i]=i*HRES/size_game_song;
				list_xf[i]=list_xi[i] + HRES/size_game_song*game_song.notes[i].dur/1000*0.9;
				list_y[i]=3*VRES/20;
				break;
			case Fa4:
				list_xi[i]=i*HRES/size_game_song;
				list_xf[i]=list_xi[i] + HRES/size_game_song*game_song.notes[i].dur/1000*0.9;
				list_y[i]=4*VRES/20;
				break;
			case Sol4:
				list_xi[i]=i*HRES/size_game_song;
				list_xf[i]=list_xi[i] + HRES/size_game_song*game_song.notes[i].dur/1000*0.9;
				list_y[i]=5*VRES/20;
				break;
			case La4:
				list_xi[i]=i*HRES/size_game_song;
				list_xf[i]=list_xi[i] + HRES/size_game_song*game_song.notes[i].dur/1000*0.9;
				list_y[i]=6*VRES/20;
				break;
			case Si4:
				list_xi[i]=i*HRES/size_game_song;
				list_xf[i]=list_xi[i] + HRES/size_game_song*game_song.notes[i].dur/1000*0.9;
				list_y[i]=7*VRES/20;
				break;
			case Do5:
				list_xi[i]=i*HRES/size_game_song;
				list_xf[i]=list_xi[i] + HRES/size_game_song*game_song.notes[i].dur/1000*0.9;
				list_y[i]=8*VRES/20;
				break;
			default:
				break;
		}
	}
	
	for(i=0;i<number_player_notes;i++)
	{
		switch(player_notes[i].freq)
		{
			case Do4:
				list_player_xi[i]=i*HRES/size_game_song;
				list_player_xf[i]=list_player_xi[i] + HRES/size_game_song*player_notes[i].dur/1000*0.9;
				list_player_y[i]=11*VRES/20;
				break;
			case Re4:
				list_player_xi[i]=i*HRES/size_game_song;
				list_player_xf[i]=list_player_xi[i] + HRES/size_game_song*player_notes[i].dur/1000*0.9;
				list_player_y[i]=12*VRES/20;
				break;
			case Mi4:
				list_player_xi[i]=i*HRES/size_game_song;
				list_player_xf[i]=list_player_xi[i] + HRES/size_game_song*player_notes[i].dur/1000*0.9;
				list_player_y[i]=13*VRES/20;
				break;
			case Fa4:
				list_player_xi[i]=i*HRES/size_game_song;
				list_player_xf[i]=list_player_xi[i] + HRES/size_game_song*player_notes[i].dur/1000*0.9;
				list_player_y[i]=14*VRES/20;
				break;
			case Sol4:
				list_player_xi[i]=i*HRES/size_game_song;
				list_player_xf[i]=list_player_xi[i] + HRES/size_game_song*player_notes[i].dur/1000*0.9;
				list_player_y[i]=15*VRES/20;
				break;
			case La4:
				list_player_xi[i]=i*HRES/size_game_song;
				list_player_xf[i]=list_player_xi[i] + HRES/size_game_song*player_notes[i].dur/1000*0.9;
				list_player_y[i]=16*VRES/20;
				break;
			case Si4:
				list_player_xi[i]=i*HRES/size_game_song;
				list_player_xf[i]=list_player_xi[i] + HRES/size_game_song*player_notes[i].dur/1000*0.9;
				list_player_y[i]=17*VRES/20;
				break;
			case Do5:
				list_player_xi[i]=i*HRES/size_game_song;
				list_player_xf[i]=list_player_xi[i] + HRES/size_game_song*player_notes[i].dur/1000*0.9;
				list_player_y[i]=18*VRES/20;
				break;
			default:
				break;
		}
	}
}

/** Funcao que le do ficheiro as melhores pontuacoes
 *
*/
int load(char ** nomes, int * pontos)
{
	FILE *txt;
	string str, ola;
	int pont, i=0;

	if((txt = fopen("highscore.txt", "r")) == NULL)
	{
		perror("Erro ao abrir ficheiro!");
		exit(1);
	}
	
	while(fgets(str,MAX,txt))
	{
		nomes[i]=(char*)malloc(sizeof(char)*strlen(str));
		str[strlen(str)-1]='\0';
		strcpy(nomes[i],str);

		//convert string to int
		fgets(ola,MAX,txt);
		pont= atoi(ola);
		pontos[i]=pont;
		i++;
		if(i==9)
			break;
	}
	fclose(txt);

	return i;
}

/** Funcao que grava no ficheiro as melhores pontuacoes
 *
*/
void save(char ** nomes, int * pontos, int num)
{
	int i=0;
	string str;

	FILE *txt;

	/* Cria Arquivo.txt no diretorio onde o programa ? executado
	caso Arquivo.txt j? exista, abre com para adicionando dados
	apartir do seu fim.
	E testa se conseguiu criar ou abrir Arquivo.txt
	*/
	if((txt = fopen("highscore.txt", "w")) == NULL)
	{
		perror("Erro ao abrir ficheiro!");
		exit(1);
	}

	while(i < num)
	{
		strcpy(str, nomes[i]);
		fprintf(txt, "%s\n", str);//imprime o nome, e o caracter de nova linha \n para o arquivo
		fprintf(txt, "%i\n", pontos[i]);	
		i++;
	}


	//fecha arquivo
	fclose(txt);
}

/** Funcao que acrescenta no local correcto a pontuacao do jogador
 *
*/
void add_highscore(int score, char* name)
{
	char * nomes[11];
	char tmp_name[20];
	int pontos[11], num=0,tmp_score=0;

	num=load(nomes, pontos);
	nomes[num]=(char*)malloc(sizeof(char)*strlen(name));
	strcpy(nomes[num],name);
	pontos[num]=score;
	int i=num;
	
	
	while(i>0)
	{
		if(pontos[i-1]<pontos[i])
		{
			tmp_score=pontos[i-1];
			strcpy(tmp_name,nomes[i-1]);
			
			pontos[i-1]=pontos[i];
			strcpy(nomes[i-1],nomes[i]);
			
			pontos[i]=tmp_score;
			strcpy(nomes[i],tmp_name);
		}
		--i;
	}
	
	if(num+1>10)
		num=8;
	save(nomes, pontos, num+1);
}
